using System;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;
using PickGold.Entities.Table;

namespace PickGold.Entities.View
{
    public class CViewRoleUser : CBaseView
    {
        //
        public const string ENTITY_NAME = "vw_sys_role_user";
        public const string ENTITY_ALIAS = "users";
        // tb_sys_user_info
        public const string ITEM_MAIL = "item_mail";
        public const string ITEM_WAP = "item_wap";
        public const string ENROL_DATE = "enrol_date";
        public const string LAST_LOGIN = "last_login";
        public const string LOGIN_TIMES = "login_times";
        public const string LAST_FROM = "last_from";
        public const string LOCK_TIME = "lock_time";
        public const string OVER_TIME = "over_time";
        //
        public const string ROLE_ID = CBaseRoleInfo.ENTITY_KEY;
        public const string ROLE_NAME = CBaseRoleInfo.ENTITY_SYMBOL;
        public const string USER_ID = CBaseUserInfo.ENTITY_KEY;
        public const string USER_NAME = CBaseUserInfo.ENTITY_SYMBOL;
        //
        private SViewRoleUser _ = null;
        //
        public CViewRoleUser() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CViewRoleUser(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CViewRoleUser(string alias) : base(ENTITY_NAME, alias) { }
        public CViewRoleUser(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SViewRoleUser());
        }
        protected void SetSchema(SViewRoleUser s)
        {
            this._ = s;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
            base.PreInitSchema();
            // tb_sys_user_info
            this._DataTable.Columns.Add(ITEM_MAIL, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(ITEM_WAP, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(ENROL_DATE, typeof(DateTime)).DefaultValue = this._.EnrolDate;
            this._DataTable.Columns.Add(LAST_LOGIN, typeof(DateTime)).DefaultValue = this._.LastLogin;
            this._DataTable.Columns.Add(LOGIN_TIMES, typeof(int)).DefaultValue = this._.LoginTimes;
            this._DataTable.Columns.Add(LAST_FROM, typeof(long)).DefaultValue = this._.LastFrom;
            this._DataTable.Columns.Add(LOCK_TIME, typeof(DateTime)).DefaultValue = this._.LockTime;
            this._DataTable.Columns.Add(OVER_TIME, typeof(DateTime)).DefaultValue = this._.OverTime;
            // te_sys_role_user
            this._DataTable.Columns.Add(ROLE_ID, typeof(long)).DefaultValue = this._.RoleID;
            //this._DataTable.Columns.Add(USER_ID, typeof(long)).DefaultValue = this._.UserID;
            //this._DataTable.Columns.Add(ITEM_NOTE, typeof(string)).MaxLength = 50;
        }
        //
        #region Property
        //
        #region tb_sys_user_info
        //
        public string ItemMail
        {
            set
            {
                this._.ItemMail = value;
                this.SetValue(ITEM_MAIL, value);
            }
            get
            {
                return this._.ItemMail;
            }
        }
        //
        public string ItemWap
        {
            set
            {
                this._.ItemWap = value;
                this.SetValue(ITEM_WAP, value);
            }
            get
            {
                return this._.ItemWap;
            }
        }
        //
        public DateTime EnrolDate
        {
            set
            {
                this._.EnrolDate = value;
                this.SetValue(ENROL_DATE, value);
            }
            get
            {
                return this._.EnrolDate;
            }
        }
        //
        public DateTime LastLogin
        {
            set
            {
                this._.LastLogin = value;
                this.SetValue(LAST_LOGIN, value);
            }
            get
            {
                return this._.LastLogin;
            }
        }
        //
        public int LoginTimes
        {
            set
            {
                this._.LoginTimes = value;
                this.SetValue(LOGIN_TIMES, value);
            }
            get
            {
                return this._.LoginTimes;
            }
        }
        //
        public long LastFrom
        {
            set
            {
                this._.LastFrom = value;
                this.SetValue(LAST_FROM, this._.LastFrom);
            }
            get
            {
                return this._.LastFrom;
            }
        }
        //
        public DateTime LockTime
        {
            set
            {
                this._.LockTime = value;
                this.SetValue(LOCK_TIME, this._.LockTime);
            }
            get
            {
                return this._.LockTime;
            }
        }
        //
        public DateTime OverTime
        {
            set
            {
                this._.OverTime = value;
                this.SetValue(OVER_TIME, value);
            }
            get
            {
                return this._.OverTime;
            }
        }
        //
        #endregion
        //
        #region te_sys_role_user
        //
        public long RoleID
        {
            set
            {
                this._.RoleID = value;
                this.SetValue(ROLE_ID, value);
            }
            get
            {
                return this._.RoleID;
            }
        }
        /*/
        public long UserID
        {
            set
            {
                this._.UserID = value;
                this.SetValue(USER_ID, value);
            }
            get
            {
                return this._.UserID;
            }
        }
        //
        public string ItemNote
        {
            set
            {
                this._.ItemNote = value;
                this.SetValue(ITEM_NOTE, value);
            }
            get
            {
                return this._.ItemNote;
            }
        }
        /*/
        #endregion
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;
            // tb_sys_user_info
            this._.ItemMail = this.GetValue<string>(ITEM_MAIL);
            this._.ItemWap = this.GetValue<string>(ITEM_WAP);
            this._.EnrolDate = this.GetValue<DateTime>(ENROL_DATE);
            this._.LastLogin = this.GetValue<DateTime>(LAST_LOGIN);
            this._.LoginTimes = this.GetValue<int>(LOGIN_TIMES);
            this._.LastFrom = this.GetValue<long>(LAST_FROM);
            this._.LockTime = this.GetValue<DateTime>(LOCK_TIME);
            this._.OverTime = this.GetValue<DateTime>(OVER_TIME);
            // te_sys_role_user
            this._.RoleID = this.GetValue<long>(ROLE_ID);
            //this._.UserID = this.GetValue<long>(USER_ID);
            //this._.ItemNote = this.GetValue<string>(ITEM_NOTE);
            //
            return true;
        }
        //
    }
    //
    public class SViewRoleUser : SBaseView
    {
        // tb_sys_user_info
        public string ItemMail = null;
        public string ItemWap = null;
        public DateTime EnrolDate = DateTime.MinValue;
        public DateTime LastLogin = DateTime.MinValue;
        public int LoginTimes = 0;
        public long LastFrom = 0;
        public DateTime LockTime = DateTime.MinValue;
        public DateTime OverTime = DateTime.MinValue;
        // te_sys_role_user
        public long RoleID = -1;
        //public long UserID = -1;
        //public string ItemNote = null;
        //
        //
    }
    //
}
//
